﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;


namespace Comment_ajax
{
    /// <summary>
    /// updateComment 的摘要说明
    /// </summary>
    public class updateComment : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            AddComment(context);
        }


        private Boolean AddComment(HttpContext context)
        {
     
            String strConn = System.Configuration.ConfigurationManager.ConnectionStrings["Comment_AjaxConnStr"].ConnectionString;
            using (SqlConnection conn = new SqlConnection(strConn))
            {
                using (SqlCommand cmd = new SqlCommand("insert into T_Comments(UserName,msg) values(@UserName,@msg)", conn))
                {
                    conn.Open();
                    cmd.Parameters.AddWithValue("@UserName", context.Request["uName"].ToString());
                    cmd.Parameters.AddWithValue("@msg", context.Request["msg"].ToString());
                    return cmd.ExecuteNonQuery() > 0 ? true : false;
                }
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}